feat: Add website binding support for the agent#12413
feat: Add website binding support for the agent#12413f2c-ci-robot[bot] merged 1 commit intodev-v2from
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f1159e4c68
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| boundAgent, err := agentRepo.GetFirst(repo.WithByWebsiteID(req.WebsiteID)) | ||
| if err == nil && boundAgent.ID > 0 { | ||
| return buserr.New("ErrAgentWebsiteInUse") | ||
| } | ||
| if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { |
There was a problem hiding this comment.
Enforce website uniqueness atomically
BindWebsite performs a read-then-write check for website_id without any transaction or DB-level uniqueness guard, so two concurrent bind requests for the same website can both pass the GetFirst(repo.WithByWebsiteID(...)) check and then both persist successfully. In that race, multiple agents end up bound to one website even though the API is supposed to return ErrAgentWebsiteInUse for the second binder.
Useful? React with 👍 / 👎.
| agent.WebsiteID = req.WebsiteID | ||
| if err := agentRepo.Save(agent); err != nil { | ||
| return err | ||
| } | ||
| return ensureOpenclawWebsiteAllowedOrigin(agent, &website) |
There was a problem hiding this comment.
Persist binding only after origin sync succeeds
The agent record is saved with the new website_id before ensureOpenclawWebsiteAllowedOrigin runs, so any downstream failure while updating OpenClaw config/env (for example config read/write or env marshal/save errors) returns an API error but leaves the DB binding committed. That creates a partial state where the user sees a failed bind request yet retries are blocked by ErrAgentWebsiteBound and allowed origins may still be unsynced.
Useful? React with 👍 / 👎.
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: wanghe-fit2cloud The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
No description provided.